package copyfiledemo01;


import java.io.*;

public class CopyFileDemo02 {
    public static void main(String[] args) throws IOException, IOException {
        //1.利用FileInputStream关联文件,再利用BufferedInputStream包装FileInputStream,提高读取效率
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("day23/风景.jpg"));

        //2.利用FileOutputStream关联文件,再利用BufferedOutStream包装FileOutStream,提高写入效率
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("day23/风景_copy_3.jpg"));

        //3.循环读写
        int b;
        while((b=bis.read())!=-1){
            bos.write(b);
            //bos.flush();
        }
        //4.关流释放资源
        bis.close();
        bos.close();
    }
}
